package com.base.controller.pts;

import com.alibaba.fastjson.JSONArray;
import com.base.api.pts.PtsService;
import com.base.vo.pts.PtsNurseShift;
import com.base.vo.pts.PtsNurseShiftTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wnhuang
 * @create 2020-09-16 13:51
 */
@RestController
@RequestMapping(value = "/pts", produces = "application/json;charset=UTF-8")
public class PtsController {

    @Autowired
    PtsService ptsService;

    @PostMapping(value = "/getNurseShiftData")
    public String getNurseShiftData(String startDate, String orgCode,String isCopy) {
        return ptsService.getNurseShiftData(startDate,orgCode,isCopy);
    }

    @GetMapping(value = "/getShiftTimeByOrgCode")
    public String getShiftTimeByOrgCode(String orgCode) {
        return ptsService.getShiftTimeByOrgCode(orgCode);
    }

    @PostMapping(value = "/saveShift")
    public String saveShift(String shiftArray) {
        List<PtsNurseShift> list = JSONArray.parseArray(shiftArray, PtsNurseShift.class);
        return ptsService.saveNurseShiftData(list);
    }

    @PostMapping(value = "/saveShiftTime")
    public String saveShiftTime(String shiftTimeArray) {
        List<PtsNurseShiftTime> list = JSONArray.parseArray(shiftTimeArray, PtsNurseShiftTime.class);
        return ptsService.saveNurseShiftTime(list);
    }

}
